const fs = require('fs');
const zlib = require('zlib'); //链式流相关语句，通过载入zlib对文件进行压缩

//var rds = fs.createReadStream('input.txt');

//var  zip= zlib.createGzip();  //压缩
//var wrs = fs.createWriteStream('data2.rar');//

var rdzip = fs.createReadStream( 'data2.rar');//解压
var unzip = zlib.createGunzip();
var wrstxt = fs.createWriteStream('data1.txt');

//rds.pipe(wrs); //管道流创建语句,优点：代码简洁；执行效率高，耗时短

//rds.pipe(zip).pipe(wrstxt);//链式流,压缩

rdzip.pipe(unzip).pipe(wrs);//解压后读入

console.log('程序执行完毕！');